package org.locker.domain.vo;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.locker.common.excel.annotation.ExcelDictFormat;
import org.locker.common.excel.convert.ExcelDictConvert;
import org.locker.domain.Position;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;


/**
 * 场地信息视图对象 lk_position
 *
 * @author winnie
 * @date 2023-10-11
 */
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = Position.class)
public class PositionVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 场地ID
     */
    @ExcelProperty(value = "场地ID")
    private Long positionId;

    /**
     * 场地名称
     */
    @ExcelProperty(value = "场地名称")
    private String name;

    /**
     * 场地描述
     */
    @ExcelProperty(value = "场地描述")
    private String describe;

    /**
     * 场地地址
     */
    @ExcelProperty(value = "场地地址")
    private String location;

    /**
     * 归属地code
     */
    private String belongingPlace;
    /**
     * 归属地字符串
     */
    private String belongingPlaceStr;

    private List<String> belongingPlaceList;

    // 自定义的setter方法
    public void setBelongingPlace(String belongingPlace) {
        if (belongingPlace != null && !belongingPlace.isEmpty()) {
            // 按逗号切割字符串
            this.belongingPlaceList = Arrays.stream(belongingPlace.split(","))
                .map(String::trim) // 去除每个字符串两边的空格
                .collect(Collectors.toList());
        } else {
            this.belongingPlaceList = null; // 或者设置为空列表
        }

        // 同时更新belongingPlace字段，如果需要的话
        this.belongingPlace = belongingPlace;
    }

    /**
     * 场地代理商
     */
    private Long agentUserId;

    private String agentUserName;


    /**
     * 代理商分润比例
     */
    private BigDecimal agentRate;

    /**
     * 场地代管理员
     */
    private Long manageUserId;
    private String manageUserName;

    /**
     * 管理员分润比例
     */
    private BigDecimal manageRate;

    /**
     * 财务管理员
     */
    private Long financeUserId;
    private String financeUserName;

    /**
     * 设备维护人员
     */
    private Long deviceUserId;
    private String deviceUserName;

    /**
     * 负责人
     */
//    @ExcelProperty(value = "负责人")
//    private String username;

    /**
     * 负责人电话
     */
//    @ExcelProperty(value = "负责人电话")
//    private String phone;

    /**
     * 经度
     */
    @ExcelProperty(value = "经度")
    private BigDecimal longitude;

    /**
     * 纬度
     */
    @ExcelProperty(value = "纬度")
    private BigDecimal latitude;

    /**
     * 营业时间
     */
    @ExcelProperty(value = "营业时间")
    private String workTime;

    /**
     * 场地二维码地址
     */
    @ExcelProperty(value = "场地二维码地址")
    private String qrCode;

    /**
     * 设备状态：online 营业,wait 待营业 , discard 已废弃
     */
    @ExcelProperty(value = "设备状态：online 营业,wait 待营业 , discard 已废弃", converter = ExcelDictConvert.class)
    @ExcelDictFormat(dictType = "position_status")
    private String status;

    /**
     * 备注
     */
    @ExcelProperty(value = "备注")
    private String remark;

    /**
     * openid
     */
    @ExcelProperty(value = "openid")
    private String openid;


    /**
     * 是否开启分账：open 开启，close关闭
     */
    @ExcelProperty(value = "是否开启分账")
    private String openSpilt;


    /**
     * 分账比例
     */
    private BigDecimal spiltRate;


    /**
     * 订单统计单价
     */
    private BigDecimal statisticsPrice;

    private Integer isShowMp;

    private String bindMpAppId;
}
